@include('admin.head')
<div class="container">
	<div class="row">
		@include('admin.side')
		<div class="col-md-10" id="content-wrapper">
			<div class="row">
					<div class="col-xs-12">
						<div class="panel panel-default">
						<div class="panel-heading">
							<h3 class="panel-title">添加/编辑技术</h3>
						</div>
						<div class="panel-body">
								<div class="form-horizontal" action="edit_tech/add">
								  <fieldset>
									<div class="form-group row">


								    <div class="form-group">
							      		<label for="select" class="col-xs-3 control-label no_padding_right">添加版块:</label>
								      	<div class="col-xs-4">
								        <select class="form-control input_size" name="type">
								          <option value="">请选择</option>
								        </select>
								      </div>
							    	</div>

									<div class="form-group">
									  <label class="col-xs-3 control-label no_padding_right">标题:</label>
									  <div class="col-xs-4">
									    <input class="form-control input_size" placeholder="" name="title" type="text">
									  </div>
									</div>

								    <div class="form-group">
								      <label class="col-xs-3 control-label no_padding_right">发布时间:</label>
								      <div class="col-xs-4">
								        <input class="form-control input_size date-time-picker" readonly placeholder="" name="create_time" type="text">
								      </div>
								    </div>


								    <div class="form-group">
								      <label for="textArea" class="col-xs-3 control-label no_padding_right">简介:</label>
								      <div class="col-xs-4">
								        <textarea class="form-control text_size" rows="3" name="description" id="textArea"></textarea>
								        <span class="help-block"></span>
								      </div>
								    </div>

					    	    	<div class="form-group">
					    	      		<label for="select" class="col-xs-3 control-label no_padding_right">内容:</label>
					    	      		<div class="col-xs-6">
											<div id="container" name="content" style="height:500px;"></div>
						    	    	</div>
					    	    	</div>
							    	<div class="form-group">
								      <div class="col-xs-12 text-center">
								      	<input type="hidden" name="tid">
								        <button type="button" id="sub" class="btn btn-primary ">提交</button>
								      </div>
								    </div>
								  </fieldset>
								</div>
							</div>
						</div>
					</div>
			</div>
		</div>
	</div>
</div>
</div>
@include("admin.footer")
@include("admin.common")
</body>

<script type="text/html" id="typeTemp">
<option value="">请选择</option>
<option value="0">开发区版块</option>
{%each list as value}
<option value="{%value.id}">{%value.company_name}</option>
{%/each}
</script>

<script type="text/javascript">
var ue = UE.getEditor('container');

$.get("get_development_user", function (data){
	console.log(data);
	if(data.success){
		var html = template("typeTemp", {list : data.data});
		$("select[name='type']").html(html);
	}
})

$("#sub").click(function(){
	var type = $("select[name='type']").val();
	var title = $("input[name='title']").val().trim();
	var create_time = $("input[name='create_time']").val().trim();
	var description = $("textarea[name='description']").val().trim();
	var content = encodeURIComponent(ue.getContent());

	if(type < 0){
		warning("", "请选择开发区");
		return;
	}
	if(title == ''){
		warning("", "标题不能为空");
		return;
	}
	if(create_time == ''){
		warning("", "发布时间不能为空");
		return;
	}
	if(description == ''){
		warning("", "简介不能为空");
		return;
	}
	if(content == ''){
		warning("", "正文内容不能为空");
		return;
	}

	$.post("add_news/save", {
		type : type,
		title : title,
		create_time : create_time,
		description : description,
		content : content
	}, function (data){
		if(data.success){
			success("", "添加成功");
			setTimeout(function(){
				window.location.href="../development";
			}, 1500)
		}
	})


})


</script>
</html>